'use client';

import { useForm } from 'antd/es/form/Form';
import React from 'react';

import { query as queryGrade } from '@/data/modules/grade/service';
import { query as querySubject } from '@/data/modules/subject/service';
import { Knowledge, KnowledgePoint } from '@/data/prisma';
import EditableTable, { IRefData } from '@/pao/web/dataEdit/dateEditEditableTable';
import {
  LightFilter, ProCard, ProColumnType, ProForm, ProFormGroup, ProFormInstance, ProFormList,
  ProFormSelect, ProFormText, ProFormTextArea, ProList, QueryFilter
} from '@ant-design/pro-components';

import * as knowledgeService from '../knowledge/service';
import { addRow, deleteRow, editRow, query } from './service';

export enum KnowledgePointType {
	Concept = '概念',
	Definition = '定义',
	Example = '例句',
	Explanation = '解说',
	Summary = '总结',
	Test = '测试',
	Application = '应用',
	Idea = '观念',
	Proposition = '命题',
	Question = '问题',
	Reasoning = '推理',
	Reference = '参考',
	Theorem = '定理',
	Proof = '证明',
	Conclusion = '结论',
	Conjecture = '猜想',
	Hypothesis = '假设',
	Method = '方法',
	Table = '表格',
	Corollary = '推论',
	Criterion = '标准',
}

const columns: ProColumnType<KnowledgePoint>[] = [
	{
		title: '编号',
		dataIndex: 'code',
		fixed: 'left',
		sorter: true,
		width: '80px',
	},
	{
		title: '名称',
		dataIndex: 'name',
		sorter: true,
		fixed: 'left',
		width: '150px',
	},
	{
		title: '类型',
		dataIndex: 'knowledgeType',
		sorter: true,
		width: '150px',
		valueType: 'select',
		valueEnum: KnowledgePointType
	},
	{
		title: '内容',
		dataIndex: 'content',
		sorter: true,
		width: '200px',
		valueType: 'code'
	},
	{
		title: '备注',
		dataIndex: 'comments',
		sorter: true,
		width: 300,
	},
];

const config = {
	headerTitle: '知识点',
	tooltip: '修改知识点信息',
}

export default function KnowledgePointControl({ refData }: IRefData<KnowledgePoint>) {
	return <EditableTable<KnowledgePoint> columns={columns} rowKey="id" config={config} deleteRow={deleteRow} query={query} editRow={editRow} addRow={addRow} refData={refData} />
}
